package com.xuecheng.content.api;

import com.xuecheng.content.model.po.CourseTeacher;
import com.xuecheng.content.service.CourseTeacherService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RequestMapping("/courseTeacher")
@RestController
@Api(value = "课程计划教师编辑接口",tags = "课程计划教师编辑接口")
public class CourseTeacherController {
    @Autowired
    private CourseTeacherService courseTeacherService;
    @GetMapping("/list/{courseId}")
    @ApiOperation("查询课程教师信息")
    public List<CourseTeacher> querylist(@PathVariable Long courseId){
        log.info("查询课程教师信息，{}",courseId);
        return courseTeacherService.queryList(courseId);
    }
    @PostMapping
    @ApiOperation("增加教师课程信息")
    public CourseTeacher save(@RequestBody CourseTeacher courseTeacher){
        log.info("增加教师课程信息,{}",courseTeacher);
        return courseTeacherService.save(courseTeacher);
    }
    @PutMapping
    @ApiOperation("修改教师课程信息")
    public CourseTeacher update(@RequestBody CourseTeacher courseTeacher){
        log.info("修改教师课程信息,{}",courseTeacher);
        return courseTeacherService.save(courseTeacher);
    }
    @DeleteMapping("/course/{courseId}/{teacherId}")
    @ApiOperation("删除教师课程信息")
    public void delete(@PathVariable Long courseId,@PathVariable Long teacherId){
        log.info("删除教师课程信息,{}",courseId,teacherId);
        courseTeacherService.delete(courseId,teacherId);
    }
}
